#Include DrawBase.ahk

class DrawRect extends DrawBase {

  color := '0xffa4ffa4', thickness := 1

  UpdateParam(size, color, solid) {
    this.thickness := size, this.color := color, this.solid := solid
  }

  BeginDraw(pos, *) {
    MouseGetPos(&_x, &_y)
    this.x := _x - pos.x, this.y := _y - pos.y
  }

  EndDraw(*) => this.data

  Draw(overlay, pos, *) {
    super.Draw(overlay, pos)
    overlay.GetMousePos(&x, &y), w := x - this.x, h := y - this.y
    if this['solid'] {
      overlay.FillRectangle(this.x, this.y, w, h, this.color)
      this.data := {
        solid: 1,
        data: [this.x, this.y, w, h, this.color]
      }
    } else {
      overlay.DrawRectangle(this.x, this.y, w, h, this.color, this.thickness)
      this.data := {
        solid: 0,
        data: [this.x, this.y, w, h, this.color, this.thickness]
      }
    }
  }

  static Render(overlay, data, *) {
    if data.solid
      overlay.FillRectangle(data.data*)
    else overlay.DrawRectangle(data.data*)
  }

}